import http from '@/utils/http';

/**
 * 获取区域树
 * @param params
 * @returns {*|Promise<any>}
 */
export const areaTreeSelectData = (params?: any) => {
  return http.get('system/area/areaTreeSelectData', {params});
}

/**
 * 获取用户区域树
 * @param params
 * @returns {*|Promise<any>}
 */
export const userAreaTreeSelectData = (params?: any) => {
  return http.get('system/area/userAreaTreeSelectData', {params});
}


/**
 * 获取区域树型表格数据
 * @param params
 * @returns {*|Promise<any>}
 */
export const getAreaTreeTableData = (params: any = {}) => {
  return http.get('system/area/areaTreeTableData', {params});
}

/**
 * 删除区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const removeArea = (params: any) => {
  return http.delete('system/area/remove', {params});
}

/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateArea = (params: any) => {
  return http.put('system/area/edit', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addArea = (params: any) => {
  return http.post('system/area/add', params);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getById = (params: any) => {
  return http.get('system/area/' + params.id);
}

/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const checkAreaNameUnique = (params: any) => {
  params.loading = false;
  return http.post('system/area/checkAreaNameUnique', params);
}

export const checkAreaCodeUnique = (params: any) => {
  params.loading = false;
  return http.post('system/area/checkAreaCodeUnique', params);
}

/**
 * 获取登录人部门的下级部门列表
 * @param params
 * @returns {*|Promise<any>}
 */
export const queryUserSubArea = (params?: any) => {
  return http.get('system/area/queryUserSubArea', {params});
}

